package com.class05.controller;

import com.class05.pojo.Student;
import com.class05.service.impl.StudentServiceImpl;

import java.util.List;

public class StudentController {

    private StudentServiceImpl studentService;

    public void setStudentService(StudentServiceImpl studentService) {
        this.studentService = studentService;
    }

    public List<Student> queryAll() {
        List<Student> studentList = studentService.findAll();
//        for (Student student : studentList) {
//            System.out.println(student);
//        }
//        stream() 将集合转换为流，forEach() 对流中的每个元素执行操作
        studentList.stream().forEach(System.out::println);
        return studentList;

    }

    public int addStudent(Student student) {
        int i = studentService.addStudent(student);
        return i;
    }

//    修改学生信息

    public int updateStudent(Student student) {
        int i = studentService.updateStudent(student);
        return i;
    }

    //    删除学生信息
    public int deleteStudent(Integer id) {
        int i = studentService.deleteStudent(id);
        return i;
    }
}
